<?php

namespace app\adminapi\export;

use Carbon\Carbon;
use app\services\user\UserServices;

class UserExport extends BaseExport
{
    protected $header = [
        '注册来源', '客户ID', '昵称', '真实姓名', '手机号码','邮箱','注册时间','最近购买时间','购买次数','客单价','积分','是否分销会员','状态'
    ];

    public function createData(array $where)
    {
        $list = app()->make(UserServices::class)->newIndex($where)['list'];

        $data = [];

        foreach ($list as $item) {
            $data[] = [
                $item['register_from'] == 1 ? 'H5' : 'PC商城',
                $item['uid'],
                $item['nickname'],
                $item['real_name'],
                $item['phone'],
                $item['mail'],
                date('Y-m-d H:i:s',$item['add_time']),
                $item['last_pay_time'] ? date('Y-m-d H:i:s',$item['last_pay_time']) : 0,
                $item['deal_number'],
                $item['deal_unit_price'],
                $item['integral'],
                '否',//字段不明,暂时写死
                $item['status'] == 1 ? '正常' : '关闭',
            ];
        }
        return $data;
    }
}